package jumpingnotes.model;

public class ResourceTypesUtil {
	static public String audioSubTypeToExt(int audioSubType) {
		switch (audioSubType) {
			case ResourceTypes.SUBTYPE_AUDIO_MP3:
				return "mp3";
			case ResourceTypes.SUBTYPE_AUDIO_SWF:
				return "swf";
			case ResourceTypes.SUBTYPE_AUDIO_3GPP:
				return "3gpp";
			case ResourceTypes.SUBTYPE_AUDIO_FLV:
				return "flv";
			case ResourceTypes.SUBTYPE_AUDIO_AAC:
				return "aac";
			default:
				return null;
		}
	}
	
	static public int getAudioSubType(String audioTypeStr) {
		if ("mp3".equals(audioTypeStr)) {
			return ResourceTypes.SUBTYPE_AUDIO_MP3;
		} else if ("aac".equals(audioTypeStr)) {
			return ResourceTypes.SUBTYPE_AUDIO_AAC;
		} else if ("3gpp".equals(audioTypeStr)) {
			return ResourceTypes.SUBTYPE_AUDIO_3GPP;
		} else if ("flv".equals(audioTypeStr)) {
			return ResourceTypes.SUBTYPE_AUDIO_FLV;
		} else if ("swf".equals(audioTypeStr)) {
			return ResourceTypes.SUBTYPE_AUDIO_SWF;
		} else {
			return ResourceTypes.SUBTYPE_AUDIO_UNKNOWN;
		}
	}
	
	static public String bookSubTypeToExt(int bookSubType) {
		return "txt";
	}
	
	static public String deploySubTypeToExt(int deploySubType) {
		String ext = audioSubTypeToExt(deploySubType);
		if (ext == null) {
			switch (deploySubType) {
				case ResourceTypes.SUBTYPE_DEPLOY_SYNC:
					return "xml";
				case ResourceTypes.SUBTYPE_DEPLOY_ZIP:
					return "zip";
				default:
					return null;
			}
		} else {
			return ext;
		}
	}

	static public String imageSubTypeToExt(int imageSubType) {
		switch (imageSubType) {
			case ResourceTypes.SUBTYPE_IMAGE_JPG:
				return "jpg";
			case ResourceTypes.SUBTYPE_IMAGE_GIF:
				return "gif";
			case ResourceTypes.SUBTYPE_IMAGE_PNG:
				return "png";
			default:
				return null;
		}
	}
}
